package com.zhixi.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zhixi.common.R;
import com.zhixi.pojo.User;
import com.zhixi.service.UserService;
import com.zhixi.utils.SendSmsUtils;
import com.zhixi.utils.ValidateCodeUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @ClassName UserController
 * @Author zhangzhixi
 * @Description 用户登录注册控制器
 * @Date 2022-7-13 22:34
 * @Version 1.0
 */
@RestController
@RequestMapping("/user")
@Slf4j
public class UserController {


    @Autowired
    private UserService userService;

    /**
     * 发送验证码
     *
     * @param user 用户信息
     * @return 验证码
     */
    @PostMapping("/sendMsg")
    public R<String> userSendMsg(@RequestBody User user, HttpSession session) {
        return userService.senMsg(user, session);
    }

    /**
     * 用户注册
     *
     * @param user 用户信息
     * @return 注册结果
     */
    @PostMapping("/login")
    public R<User> login(@RequestBody User user, HttpSession session) {
        return userService.login(user, session);
    }
}
